/**
 * Created with IntelliJ IDEA
 * Description:
 * User: Administrator
 * Data: 2023 - 07 - 03
 * Time: 13:49
 */
class ListNode {
    int val;
    ListNode next;
    ListNode(int x) {
        val = x;
    }
}
public class Solution {
        public int[] reversePrint(ListNode head) {
            int num = 0;
            ListNode cur = head;
            while(cur != null) {
                num++;
                cur = cur.next;
            }
            int[] array = new int[num];
            cur = head;
            while(cur != null) {
                array[num - 1] = cur.val;
                cur = cur.next;
                num--;
            }
            return array;
        }
    }

